package game;

import com.jme3.app.state.AbstractAppState;
import com.jme3.app.state.AppStateManager;

public class ResolutionAppState extends AbstractAppState {
    private float timeSinceLastTick = 0f;
    protected ResolutionInputHandler inputHandler = new ResolutionInputHandler();
    
    @Override
    public void stateAttached(AppStateManager stateManager) {
        super.stateAttached(stateManager);
	inputHandler.register();
        ResolutionController.startResolution();
    }
    
    @Override
    public void stateDetached(AppStateManager stateManager) {
        super.stateDetached(stateManager);
        DataStore.inputManager.removeListener(inputHandler);
    }
    
    @Override
    public void update(float tpf) {
        timeSinceLastTick += tpf;
        if(timeSinceLastTick >= DataStore.TIME_PER_TICK) {
            ResolutionController.tick();
            timeSinceLastTick = 0f;
        }
    }
}
